<template>
	<view class="content">
		<image class="top-head" src="../../static/top_head.png" mode="aspectFit"></image>
		<view>
			<image class="name" src="/static/clearBlack/name2.png" mode="aspectFit"></image>
		</view>
		<view class="center">
			<view class="title">
				进度查询
			</view>
			<view class="query">
				<text>线索编号：</text>
				<u--input v-model="number" disabledColor="#ffffff" border="surround">

				</u--input>
				<text>举报类别：</text>
				<view class="" @click="select">
					<u--input v-model="queryType" disabled disabledColor="#ffffff" placeholder="请选择" border="surround">
						<u-icon slot="suffix" name="arrow-right"></u-icon>
					</u--input>
				</view>
			</view>
			<view class="captcha">
				<view style="font-weight: 700;">
					验证码：
				</view>
				<view class="captcha-item">
					<u--input v-model="captchavalue" border="surround"></u--input>
					<image :src="captchaImage" mode="scaleToFill" @click="changCaptcha"></image>
				</view>
			</view>
			<view class="button" @click="query">
				<text>我要查询</text>
			</view>

			<view class="progress" v-show="statu">
				<!-- 当前进度为： -->
				<text style="font-weight: 700; font-size: 40rpx; color: #8b050b;">{{statu | statuFilter}}</text>
			</view>

		</view>
		<view class="bottom">
			<p>版权所有 © 中共邵阳市委政法委员会</p>
			<!-- <p style='margin: 30rpx 0;'>京ICP备19020621号-1</p> -->
		</view>

		<u-picker :show="showSelect" :columns="[columns]" @cancel="cancel" keyName='name' @confirm='confirm'>
		</u-picker>
	</view>
</template>

<script>
	import {
		queryProgress
	} from '@/config/api.js'
	import {
		captcha
	} from '@/pages/mixin/captcha.js'


	export default {
		filters: {
			statuFilter(val) {
				const status = {
					1: '您的线索已收到，待处理',
					2: '处理中',
					3: '已经处理'
				}
				return status[val]
			}
		},
		// mixins: [captcha],
		data() {
			return {
				captchavalue: '',
				captchaImage: uni.$u.http.config.baseURL + '/captcha/api' + uni.getStorageSync('token'),
				number: '',
				showSelect: false,
				queryType: '',
				type: '',
				statu: "",
				columns: [{
						name: '未成年人保护',
						type: 'harmMinors'
					},
					{
						name: '打击扫黑除恶',
						type: 'gangCrimes'
					},
					{
						name: '打击整治养老诈骗',
						type: 'endowmentInsuranceFraud'
					},
				]
			}
		},
		onLoad() {
			// setInterval(() => {
			// 	this.countDownTime()
			// }, 1000)

		},
		onShow() {
			this.changCaptcha()
		},
		methods: {
			changCaptcha() {
				this.captchaImage += ('?' + Math.random())
			},
			query() {
				queryProgress({
					no: this.number,
					type: this.type,
					captcha: this.captchavalue
				}).then(res => {
					this.statu = ''
					if (res.code == 1) {
						if (!res.data) {
							uni.showToast({
								title: '未查询到举报线索',
								icon: 'error'
							})
						} else {
							this.statu = res.data.status
						}
					}
					this.changCaptcha()
				})
			},
			select() {
				uni.hideKeyboard()
				this.showSelect = true
			},
			cancel() {
				this.showSelect = false
			},
			confirm(e) {
				this.type = e.value[0].type
				this.queryType = e.value[0].name
				this.showSelect = false
			},
			// 倒计时
			countDownTime() {
				if (this.buttonTime === 0) {
					clearInterval()
					this.timeOk = true
					return
				}
				this.buttonTime--
			}
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;
		width: 100%;
	}

	/deep/.u-input--radius {
		background-color: #fff;
	}

	.content {
		width: 100%;
		min-height: 100%;
		background: url(~@/static/bg_long.jpg);
		background-size: cover;
		position: relative;
		padding-bottom: 20rpx;

		.top-head {
			width: 100%;
			margin-top: -130rpx;
		}

		.name {
			width: 100%;
			margin-top: -360rpx;
			// height: 40rpx;
		}

		.center {
			margin-top: -100rpx;

			.title {
				letter-spacing: 5rpx;
				text-align: center;
				font-size: 40rpx;
				font-weight: 700;
				color: #004789;
				margin: 20rpx auto;
				width: 600rpx;
				height: 80rpx;
				border-bottom: 2rpx solid #c7a4a4;
			}

			.query {
				padding: 80rpx;
				line-height: 100rpx;
				font-size: 30rpx;

				text {
					font-size: 30rpx;
					font-weight: 600;
				}
			}

			.captcha {
				padding: 80rpx;

				.captcha-item {
					display: flex;

					u--input {
						width: 200rpx;
					}

					image {
						margin-left: 20rpx;
						width: 200rpx;
						height: 80rpx;
						background-color: #ccc;
					}
				}
			}

			.button {
				background-color: #8b050b;
				height: 100rpx;
				width: 470rpx;
				border-radius: 10rpx;
				color: #fff;
				font-size: 40rpx;
				line-height: 100rpx;
				text-align: center;
				letter-spacing: 5rpx;
				margin: 40rpx auto;
			}

			.progress {
				height: 80rpx;
				text-align: center;
				line-height: 80rpx;
			}
		}

		.bottom {
			margin-top: 100rpx;
			text-align: center;
			line-height: 38rpx;
			font-size: 30rpx
		}
	}
</style>
